<%@ page language="java" contentType="text/html; charset=UTF-8" import="com.zxmr.domain.component.Component,com.zxmr.domain.service.ComponentService,java.util.*"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LoveFace 整形美容办公系统</title>
    <link rel="stylesheet" type="text/css" href="easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="easyui/demo.css">
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.json-2.4.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="js/chart/highcharts.js"></script>
	<script type="text/javascript" src="js/chart/modules/exporting.js"></script>
	<script type="text/javascript" src="component/utility/js/Task.js"></script>
	<script type="text/javascript" src="js/divloading.js"></script>
	<script type="text/javascript" src="js/report.js"></script>
	<script type="text/javascript" src="component/customer/js/customerAction.js"></script>
	<script type="text/javascript" src="component/utility/js/addFile.js"></script>
	
<link rel="stylesheet" href="themes/main.css" type="text/css" />

<style>

</style>
</head>
<%
	com.zxmr.domain.account.User user = (com.zxmr.domain.account.User)request.getSession().getAttribute("user");
	List<Component> components = null;
	System.out.println("session is empty?");
	
	if(user == null)
	{
		System.out.println("session is empty");
		response.sendRedirect("login.html");
	}else
	{
		ComponentService service = new ComponentService();
		components = service.queryAllByCompany(user.getCompany());
	}
%>
<body class="html front not-logged-in no-sidebars page-node" >	  	  
<div id="header">
   <div id="header-container"> 
      <a id="logo" href="/" title="CSS Menu Maker"></a>		
        <div class="region region-menu">
    <div id="block-system-main-menu" class="block block-system block-menu block-odd clearfix">
  <div class="block-inner">

                		
		<div class="content" >
		  <ul class="indexMenu"><li class="first leaf home mid-218"><a href="/" class="active">首页</a></li>
<li class="expanded menus mid-551"><a href="" title="CSS Menus">Menus</a><ul class="indexMenu"><li class="first leaf drop-down mid-1313"><a href="" title="Drop Down Menus">Drop Down</a></li>
<li class="leaf responsive mid-2899"><a href="">Responsive</a></li>
<li class="leaf vertical mid-1316"><a href="" title="Vertical Menus">Vertical</a></li>
<li class="leaf jquery mid-2167"><a href="" title="jQuery Menus">jQuery</a></li>
<li class="leaf flyout mid-1314"><a href="" title="Flyout Menus">Flyout</a></li>
<li class="leaf accordion mid-3314"><a href="">Accordion</a></li>
<li class="leaf horizontal mid-1315"><a href="" title="Horizontal Menus">Horizontal</a></li>
<li class="leaf pure-css mid-1318"><a href="">Pure CSS</a></li>
<li class="leaf tabbed mid-1317"><a href="" title="Tabbed Menus">Tabbed</a></li>
<li class="last leaf premium-menus mid-2163"><a href="" title="Premium Menus">Premium Menus</a></li>
</ul></li>
<li class="expanded plugins mid-2896"><a href="">Plugins</a><ul class="menu"><li class="first leaf dreamweaver mid-616"><a href="">Dreamweaver</a></li>
<li class="last leaf wordpress mid-2901"><a href="">Wordpress</a></li>
</ul></li>
<li class="leaf blog mid-555"><a href="">Blog</a></li>
<li class="last leaf support mid-1033"><a href="">Support</a></li>
</ul>		</div>

  </div>
</div> <!-- /block-inner /block -->  </div>
      <ul id="user-menu" class="clearfix">
         				 <!-- <li class="register"><a href="/user/register">Sign Up</a></li> -->
         <li class="register"><a href="companyRegister.html">购买</a></li>
         <li class="login"><a href="login.html">登陆</a></li>
               </ul>      
         </div><!-- /header-container -->
</div>
<div id="mainwrap">
<div id="content">
<div class="indexleft">
<div style="width:230px" class="shadowBox margin10">
	<%
	
	if(components != null && !components.isEmpty())
	{
		for(Component com : components)
		{

	%>
	<div class="rappidLink_item height40" onclick="workbenchJs.open1('component/<%=com.getName()%>/index.html',this)" style="cursor: pointer;">
    <div class="rappidLink_info TextMiddle40"><%=com.getDisplay()%></div>
	</div>
<%
		}
	}
%>
</div>
<div id="cssmenuId" style="width:230px" class="shadowBox margin10">
</div>
</div>
<div id="indexRight">
	<div style="float:left;clear:both;width:auto;width:100%">
		<div class="padding20" id="notification">
		</div>
	</div>
	<div style="float:left;clear:both;width:auto;width:100%">
		<div id="component">
			
		</div>
	</div>

</div>

 <script>
 (function(workbenchJs, $, undefined ) {
	 workbenchJs.init = function(){
		$('#menu').panel();
		$('#component').panel();
		$('#component').panel("close");
		
		divAjaxLoading('cssmenuId');
		loadRappidLinks();
		workbenchJs.loadNotification();
		setInterval("workbenchJs.loadNotification()",6000000);
		workbenchJs.open1('component/customer/index.html',this);
	};
	function loadRappidLinks(){
		workbenchJs.loadData("dispatch/manage/page/all",workbenchJs.loadRapidLinksResult,"查询快捷链接");
	}
	 workbenchJs.open1 = function(url,a){
		$('body>div.menu-top').menu('destroy');
		$('body>div.window>div.window-body').window('destroy');
		$('#menu').panel("close");
		$('#component').panel("open");
		$('#component').panel('refresh',url);
	};
	workbenchJs.loadNotification = function()
	{
		workbenchJs.loadData("dispatch/utility/notification/mine",workbenchJs.loadNotificationResult,"查询我的通知");
	};
	var addPageDia = null;
	workbenchJs.addPageDiag = function()
	{
		addPageDia = $('<div/>').dialog({
			href : 'component/manage/pageAction.html',
			width : 350,
			height : 250,
			modal : true,
			title : '添加快捷链接',
			onClose : function() {
				$(this).dialog('destroy');
			},
			buttons:[]
			});
	};
	workbenchJs.closeAddPage = function(){
		addPageDia.dialog("close");
		loadRappidLinks();
	};
	function deletePage(id){
		var i = $(id).attr('pageId');
		workbenchJs.loadData("dispatch/manage/page/delete?id="+i,workbenchJs.deletePageResult,"删除快捷链接");
	}
	workbenchJs.deletePageResult = function(result){
		loadRappidLinks();
	};
	workbenchJs.loadNotificationResult = function(result)
	{
		var res = result.result;
        if(res == "SUCCESS")
        {
        	$('#notification').hide();
        	var html = "";
        	var payload = jQuery.parseJSON(result.payload.value);
        	$(payload).each(function(index){
        		var t = '[知道了]';
        		html+='<div class="height40 TextMiddle40 card_item_toolbar shadowBox"><a href="#" onclick="javascript:workbenchJs.notificationAwared('
        					+payload[index].id+',this)">'+t+'</a>  '+payload[index].content+'</div>';
        	});
        	$('#notification').html(html);
        	$('#notification').show();
        }
	};
	workbenchJs.notificationAwared = function(id,div){
		workbenchJs.loadData("dispatch/utility/notification/aware?id="+id,workbenchJs.notificationAwaredResult,"");
		$(div).parent().hide();
	};
	workbenchJs.notificationAwaredResult = function(result){
		
	};
	workbenchJs.loadRapidLinksResult = function(result)
	{
    	var res = result.result;
    	divAjaxLoadEnd('cssmenuId');
        if(res == "SUCCESS")
        {
        	var payload = jQuery.parseJSON(result.payload.value);
        	var html = "";
        	var count = 0;
        	$(payload).each(function(index){
        		count++;
        		html+='<div class="rappidLink_item height60" onclick="workbenchJs.open1(\'component/'+
        				payload[index].pageURL+'\',this)"><div class="rappidLinkDelete"><a class="rappidLinkDeleteA" href="#" pageId="'
        				+payload[index].id+'"></a></div><div class="rappidLink_Pic imgMiddle"><span></span><img style="48Img" src="'+payload[index].image
        				+'"></div><div class="rappidLink_info TextMiddle60">'+payload[index].name+'</div></div>';
        	});
        	
        	html+='<div class="rappidLink_item height60" onclick="workbenchJs.addPageDiag()"><div class="rappidLink_Pic imgMiddle"><span></span><img style="48Img" src="images/add.png"></div><div class="rappidLink_info TextMiddle60">添加快捷链接</div></div>';
        	
        	$("#cssmenuId").html(html);
        	$('.rappidLink_item').css({cursor:'pointer'});
    		$('.rappidLink_item').bind('mouseover',function(){
    			rappidLinkItemOver(this);
    		});
    		$('.rappidLink_item').bind('mouseout',function(){
    			rappidLinkItemOut(this);
    		});
    		$('.rappidLinkDeleteA').bind('click',function(){
    			deletePage(this);
    			return false;
    		});
        }else if(res == "COMPONENT_ERROR")
        {
        	$.messager.alert("Error",result.payload.value);
        }else
        {
        	$.messager.alert("Error",result.result);
        }
	};
	function rappidLinkItemOver(id)
	{
		$(id).addClass('rappidLink_row-over');
		var deleteDiv = $(id).find('.rappidLinkDelete');
		
		$(deleteDiv).show();
	}
	function rappidLinkItemOut(id)
	{
		$(id).removeClass('rappidLink_row-over');
		var deleteDiv = $(id).find('.rappidLinkDelete');
		
		$(deleteDiv).hide();
	}
	
	workbenchJs.loadData = 	function(url,func,action){
		$.ajax({
            type: "post",
            url: url,
            dataType:"json",
            success: function (result) {
            	
                if(result.result == "SUCCESS")
                {
                	func(result);
                }else if(result.result == "NOT_AUTHORIZED")
                {
                	$.messager.alert("Error","操作: "+action+" 错误信息: 您没有权限 ");
                }else if(result.result == "COMPONENT_ERROR")
                {
                	$.messager.alert("Error","操作: "+action+" 错误信息: "+result.payload.value);
                }else
                {
                	$.messager.alert("Error","操作: "+action+" 错误信息: "+result.result);
                }
            }
            
        });
	};
 }( window.workbenchJs = window.workbenchJs || {}, jQuery ));

 $(function(){
	 workbenchJs.init();
 });
</script>

</div><!-- /content -->
</div><!-- /mainwrap -->
<div id="footer">
  <div class="container clearfix">
    <div class="panel about">
      <h3>LoveFace</h3>
      <ul class="indexMenu"><li class="first leaf contact mid-768"><a href="/contact" title="">关于我们</a></li>
			<li class="leaf guest-post mid-1032"><a href="/guest-post" title="">我们的客户</a></li>
		<li class="leaf terms-of-use-privacy-policy mid-770"><a href="/terms-of-use-privacy" title="">产品介绍</a></li>
		<li class="last leaf site-map mid-771"><a href="/site-map" title="">服务条款</a></li>
	</ul>        
    </div>
    <div class="panel share">
      <h3>客户支持</h3>
      <ul>
        <li class="blog">电话: 18342079180</li>
        <li class="facebook">QQ : 250004823</li>
        <li class="twitter">微信 : 18211077638</li>      
      </ul>
    </div>
    <div class="panel newsletter">
      <h3>关注我们</h3>
      <p>订阅我们的最新动态</p>
      <form action="" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate clearfix" target="_blank">
      <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="orange-button">
      </form>
    </div>
  </div>  
</div>
</body>
</html>
